package cn.stylefeng.guns.sys.modular.system.service;

import cn.stylefeng.guns.sys.modular.system.entity.OperationLog;
import cn.stylefeng.guns.sys.modular.system.mapper.OperationLogMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 操作日志 服务实现类
 * </p>
 *
 * @author stylefeng
 * @since 2018-12-07
 */
@Service
public class OperationLogService extends ServiceImpl<OperationLogMapper, OperationLog> {

    /**
     * 获取操作日志列表
     *
     * @author fengshuonan
     * @Date 2018/12/23 5:41 PM
     */
    public List<Map<String, Object>> getOperationLogs(Page page, String beginTime, String endTime, String logName, String s) {
        return this.baseMapper.getOperationLogs(page, beginTime, endTime, logName, s);
    }
    /**
     * 获取操作日志列表
     *
     * @author fengshuonan
     * @Date 2018/12/23 5:41 PM
     */
    public List<Map<String, Object>> archiveLog(String beginTime, String endTime, String logName, String s) {
        return this.baseMapper.archiveLog( beginTime, endTime, logName, s);
    }

    public Object getChartsData(String s) {
        List<Map<String, Object>> chartsData = this.baseMapper.getChartsData(s);
        HashMap<Object, Object> newHashMap = Maps.newHashMap();
        ArrayList<String> date = Lists.newArrayList();
        ArrayList<Long> numList = Lists.newArrayList();
        for (Map map:chartsData) {
            String m = (String) map.get("m");
            Long num = (Long) map.get("num");
            date.add(m);
            numList.add(num);
        }
        newHashMap.put("date",date);
        newHashMap.put("numList",numList);
        return newHashMap;
    }

    public Object getChartsData2(String valueOf) {
        List<Map<String, Object>> chartsData = this.baseMapper.getChartsData2(valueOf);
        return chartsData;
    }
}
